package com.leyou.item.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pojo.Brand;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Author: Saka
 * Date: 2019/1/15
 * Time: 20:55
 */
public interface BrandMapper extends Mapper<Brand> {

    @Insert("insert into tb_category_brand (category_id,brand_id) values (#{cid},#{bid})")
    void insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid);
    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    void deleteBrandCategory(@Param("bid") Long bid);
    @Delete("delete from tb_brand where id = #{bid}")
    void deleteByBrandId(@Param("bid") Long bid);
    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    void deleteByCategoryBrandId(@Param("bid") Long bid);
    @Select("select b.* from tb_category_brand cb left join tb_brand b on cb.brand_id = b.id where cb.category_id = #{cid}")
    List<Brand> queryBrandByCategory(@Param("cid") Long cid);
}
